import fs from 'fs'
import selenium from 'selenium-webdriver'
const {Builder, By, Key, until} = selenium
import * as utils from './common/utils.cjs'
import wdio from 'webdriverio'

//const fs = require('fs')
//const {Builder, By, Key, until} = require('selenium-webdriver')
//const utils = require('./utils.cjs')
//const wdio = require('webdriverio')



const opts = {
    path: '/wd/hub',
    port: 4723,
    capabilities: {
        "platformName": "Android",
        "platformVersion": "6.0.1",
        "deviceName": "xiaomi",
        "app": "e:/Instagram_v208.0.0.32.135_apkpure.com.apk",
        "appPackage": "com.instagram.android",
        "appActivity": "com.instagram.mainactivity.MainActivity",
        "automationName": "UiAutomator2",
        "newCommandTimeout": 3600,
        "noReset": true
    }
}

let client = null

export async function createInstagramClient() {
    client = await wdio.remote(opts)
    return client
}

export async function closeInstagramClient() {
    return await client.deleteSession()
}
